package threads.wait;

import java.util.concurrent.Executor;

public class JoinTest {
    public static void main(String[] args) {

        Executor executor = new Executor() {
            @Override
            public void execute(Runnable command) {
                Thread t = new Thread(command);
            }

        };

        final Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(1);
            }
        });
        final Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    t1.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(2);
            }
        });
        final Thread t3 = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    t2.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(3);
            }
        });
        t1.start();
        t2.start();
        t3.start();
    }
}
